#![macro_use]

pub mod logger;
pub mod peripheral;
pub mod thread;

use linked_list_allocator::LockedHeap;
use core::alloc::Layout;
pub use nrf52832_hal as hal;

#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
const HEAP_SIZE: usize = 32 * 1024; // in bytes

// define what happens in an Out Of Memory (OOM) condition
#[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! {
    panic!("Alloc error.");
}

pub fn init_alloc() {
    unsafe { ALLOCATOR.lock().init(cortex_m_rt::heap_start() as usize, HEAP_SIZE) };
}
